
import 'dart:convert';

import 'package:bot_toast/bot_toast.dart';
import 'package:bruno/bruno.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:chewie/chewie.dart';
import 'package:extended_image/extended_image.dart';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:video_player/video_player.dart';

import '../../common/colors.dart';
import '../../components/bottom_page.dart';
import '../../components/chewie_player_page.dart';
import '../../services/address.dart';
import '../../services/dio_manager.dart';
import '../../utils/persisten_storage.dart';
import 'new_detail_page.dart';
import 'news_model.dart';

class NewSearchPage extends StatefulWidget{

  String keyWord;

  NewSearchPage(this.keyWord);

  List<String> contents = [
    "mc20",
    "sony A6300系列",
    "sony a7",
    "sony 黑卡",
    "iphone xr",
    "'耐克'店铺",
    "mc20",
    "123",
    "321",
  ];


  List<String> hisArray = [
    "爱国文章",
    "热门文章",
    "当前文章",
    "搞笑恶搞",
    "小程序开发",
  ];


  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return NewSearchPageState();
  }
}


class NewSearchPageState extends State<NewSearchPage> {

  String searchValue = "";

  int page = 1;

  List dataList = [];


  late VideoPlayerController _videoPlayerController1;

  late ChewieController _chewieController;

  bool _isPlaying = false;

  EasyRefreshController _esController = EasyRefreshController();
  static const double titleFontSize = 16;



  TextEditingController _controller = new TextEditingController();




  /// 发送请求
  void requestData(String keyWord)async{
    var  params = {
      'page':page,
      'limit':100,
      's':keyWord
      // 'state':state
    };

    var json = await DioManager().kkRequest(Address.newsList,
        header: {'access_token': await PersistentStorage().getStorage('acctoken'),
          'user_id':await PersistentStorage().getStorage('uid'),
          'company_id':await PersistentStorage().getStorage('companyId')
        },contentType: 'application/json; charset=utf-8',params: params,method: 'get');

    NewsModel model = NewsModel.fromJson(json);


    if(page == 1){
      _esController.resetLoadState();
      dataList.clear();
      dataList.addAll(model.data!);
    }else{
      if(model.data!.length>0){
        dataList.addAll(model.data!);
      }else if(json['data'].length-1 <= 0){
        _esController.finishLoad(success: true,noMore: true);
        // _esController.finishLoad(success: true, noMore: true);
        // COToast.show('暂无更多');
        BotToast.showText(text: '暂无更多');
      }
    }
    setState(() {

    });


    // if(isHeader==true){
    //   imageCache.clear();
    //   page = 1;
    //   _easyRefresh.resetLoadState();
    //   dataList.clear();
    //   // dataArr.insert(0,'[]');
    //   dataList.addAll(model.data!);
    //   setState(() {
    //
    //   });
    // }else{
    //   if(model.data == null){
    //     BotToast.showText(text: '暂无更多');
    //     _easyRefresh.finishLoad(noMore: true);
    //     return;
    //   }
    //   dataList.addAll(model.data!);
    // }
    setState(() {

    });
  }
  @override
  void initState() {
    super.initState();


    // requestDataKeyWord(widget.keyWord);


    requestData(widget.keyWord);

    _esController = EasyRefreshController();

    _videoPlayerController1 = VideoPlayerController.network('http://www.zyfchina.com/templates/default/vedio/zyf.mp4')..addListener(() {

      final bool isPlaying = _videoPlayerController1.value.isPlaying;

      if (isPlaying != _isPlaying) {
        setState(() { _isPlaying = isPlaying; });
      }

    })..initialize().then((value){
      setState(() {});

    });
  }


  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }


  @override
  Widget build(BuildContext context) {
    // TODO: implement build

    double statusHeight = MediaQuery
        .of(context)
        .padding
        .top;
    return Scaffold(
      appBar: AppBar(
        title: Text(''),
        backgroundColor: AppColor.themeColor,
      ),

      body:dataList.length ==0?Container(child: Center(
        child: Text('没有找到关于\'${widget.keyWord}\'的相关内容',style: TextStyle(fontWeight: FontWeight.normal),),
      ),):searchResulf(),
    );
  }
  Widget getHistoryWidget() {
    return Column(
      children: <Widget>[
        Container(
            alignment: Alignment.centerLeft,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Text(
                  "文章搜索",
                  style: TextStyle(fontWeight: FontWeight.bold),
                ),
                // InkWell(
                //   onTap: (){
                //
                //   },
                //   child: Icon(Icons.delete_forever,
                //       color: Colors.redAccent, size: 20),
                // )
              ],
            )),
        SizedBox(
          height: 26,
        ),
        SingleChildScrollView(
          child: Wrap(
            spacing: 6,
            runSpacing: 6,
            children: List.generate(widget.hisArray.length, (index) {
              return InkWell(
                onTap: () {
                  setState(() {
                    searchValue = widget.hisArray[index];
                  });
                  _controller.text = searchValue;
                },
                child: Chip(
                  backgroundColor: Colors.grey[150],
                  label:
                  Text(widget.hisArray[index], style: TextStyle(fontSize: 12)),
                ),
              );
            }),
          ),
        )
      ],
    );
  }


  Widget searchResulf(){
    return Container(
        child: EasyRefresh.custom(
          controller: _esController,
          header: MaterialHeader(),
          footer: MaterialFooter(

          ),
          onRefresh: () async {
            if (mounted) {
              setState(() {
                page = 1;
                requestData(widget.keyWord);
              });
            }
          },

          onLoad: () async {
            if (mounted) {
              setState(() {
                page++;
                requestData(widget.keyWord);
                // _count += 20;
              });
            }

            // await Future.delayed(Duration(seconds: 1), () {
            //
            // });
          },

          slivers: [
            SliverList(
              delegate: SliverChildBuilderDelegate(
                  _buildListItem, childCount: dataList.length),
            )
          ],
        )
    );

  }

  Widget _buildListItem(BuildContext context, int a) {
    NewsListModel model = dataList[a];

    if (model.appStyle == '文本') {
      return GestureDetector(
        child: genContentList(a),
        onTap: (){
          Get.to(NewDetailPage(model.id.toString()));
        },
      );
    } else if (model.appStyle== '右图左文本') {
      return GestureDetector(
        child: getRowleftTextRightPic(a),
        onTap: (){
          Get.to(NewDetailPage(model.id.toString()));
        },
      );
    }
    else if (model.appStyle == '左图右文本') {

      return GestureDetector(
        child: getRowleftPicRightText(a),
        onTap: (){
          Get.to(NewDetailPage(model.id.toString()));
        },
      );
    }
    else if (model.appStyle == '上标题下三图') {

      return GestureDetector(
        child: getRowTopTextBottomThree(a),
        onTap: (){
          Get.to(NewDetailPage(model.id.toString()));
        },
      );
    }
    else if (model.appStyle == '上标题下一图') {

      return GestureDetector(
        child: getRowTopTextBottomOne(a),
        onTap: (){
          
          Get.to(NewDetailPage(model.id.toString()));
        },
      );
    }
    else if (model.appStyle == '上一图下标题') {
      return GestureDetector(
        child: getRowTopPicBottomText(a),
        onTap: (){
          Get.to(NewDetailPage(model.id.toString()));
        },
      );
    }
    else if (model.appStyle == '上标题下视频') {
      return GestureDetector(
        child: getRowTopTextBottomVideo(a),
        onTap: (){
          Get.to(NewDetailPage(model.id.toString()));
        },
      );
    }
    return Container(color: Colors.blue,);
  }

  /// 纯文本
  genContentList(int a) {
    NewsListModel model = dataList[a];

    return Container(
      // height: 160,
      margin: EdgeInsets.only(top: 0),
      child: Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: <Widget>[
          Container(
            child:Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Container(

                  child: Text(model.title,style: TextStyle(fontWeight: FontWeight.w400,fontSize: titleFontSize),),
                  width: Get.width-10,
                  color: Colors.white,
                  padding: EdgeInsets.only(left:15,right: 15,top: 10),
                ),
                Container(
                    width: Get.width,
                    margin: EdgeInsets.only(top: 20),
                    color: Colors.white,
                    padding: EdgeInsets.only(left:15,right: 15),
                    child:Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            Text('${model.souce}',style: TextStyle(fontSize: 10,color: AppColor.smallTextColor),),
                            SizedBox(width: 5,),
                            Text('${model.dateBeauty}',style: TextStyle(fontSize: 10,color: AppColor.smallTextColor),),
                            SizedBox(width: 5,),
                            Text('${model.comments}评论',style: TextStyle(fontSize: 10,color: AppColor.smallTextColor),)
                          ],
                        ),
                        GestureDetector(
                          child: Image.asset('images/dele.png',width: 10,height: 10,),
                          onTap: (){
                            List<BrnCommonActionSheetItem> actions = [];
                            actions.add(BrnCommonActionSheetItem(
                              '色情低俗',
                              actionStyle: BrnCommonActionSheetItemStyle.link,
                            ));
                            actions.add(BrnCommonActionSheetItem(
                              '政治敏感',
                              actionStyle: BrnCommonActionSheetItemStyle.link,
                            ));
                            actions.add(BrnCommonActionSheetItem(
                              '广告',
                              actionStyle: BrnCommonActionSheetItemStyle.link,
                            ));
                            actions.add(BrnCommonActionSheetItem(
                              '令人恶心',
                              actionStyle: BrnCommonActionSheetItemStyle.link,
                            ));
                            actions.add(BrnCommonActionSheetItem(
                              '其他',
                              actionStyle: BrnCommonActionSheetItemStyle.link,
                            ));
                            // 展示actionSheet
                            showModalBottomSheet(
                                context: context,
                                backgroundColor: Colors.transparent,
                                builder: (BuildContext context) {
                                  return BrnCommonActionSheet(
                                    title: "请选择举报类型",
                                    actions: actions,
                                    clickCallBack: (
                                        int index,
                                        BrnCommonActionSheetItem actionEle,
                                        ) {
                                      String title = actionEle.title;
                                      BrnToast.show("title: $title, index: $index", context);
                                    },
                                  );
                                });
                          },
                        )
                      ],
                    )
                )
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 15,right: 15,top: 5),
            color: AppColor.lineColor,
            height: 0.5,
            width: Get.width,
          )
          // Divider(color: Colors.grey[180],height: 1,)
        ],
      ),
    );
  }

  /// 左文右图
  getRowleftTextRightPic(int a){

    NewsListModel model = dataList[a];

    return Container(
        color: Colors.white,
        child: Column(
          children: [
            Row(
              mainAxisAlignment:MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  width: Get.width/3*2,
                  // color: Colors.yellow,
                  constraints: BoxConstraints(
                      maxHeight: 90,
                      minHeight: 40
                  ),
                  padding: EdgeInsets.only(left: 15,top: 10),
                  child:  Column(
                    crossAxisAlignment:CrossAxisAlignment.start,
                    children: [
                      Container(
                        margin: EdgeInsets.only(right: 5),
                        // color: Colors.red,
                        child:Text(model.title,
                          style: TextStyle(fontWeight: FontWeight.w400,fontSize: titleFontSize),maxLines: 2,overflow: TextOverflow.ellipsis,),
                      ),
                      // SizedBox(height: 1,),
                      SizedBox(height: 20,),
                      Row(
                        children: [
                          Text('${model.souce}',style: TextStyle(fontSize: 10,color: Colors.grey),),
                          SizedBox(width: 5,),
                          Text('${model.dateBeauty}',style: TextStyle(fontSize: 10,color: Colors.grey),),
                          SizedBox(width: 5,),
                          Text('${model.comments}评论',style: TextStyle(fontSize: 10,color: Colors.grey),)
                        ],
                      )

                    ],
                  ),
                ),

                Container(
                  margin: const EdgeInsets.only(top: 0,right: 20),
                  clipBehavior: Clip.antiAlias,
                  decoration:  const BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(8.0)),
                    color: Colors.white,
                  ),

                  // child: Image.network(itme.appImages.length == 0?'':'${Address.homeHost}${itme.appImages[0].image}',width: 75,height: 120,fit: BoxFit.cover,),
                  child: Container(
                    clipBehavior: Clip.antiAlias,
                    decoration:  const BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(2.0)),
                    ),
                    width: 100,
                    height:70,
                    // child: Image.network(itme.appImages.length == 0?'':'${Address.homeHost}${itme.appImages[0].image}',width: 75,height: 120,fit: BoxFit.cover,),
                    child: ExtendedImage.network(
                      '${Address.homeHost}${model.images}',
                      fit: BoxFit.cover,cache: true,
                    ),

                  ),
                ),
              ],
            ),
            // Row(
            //   mainAxisAlignment:MainAxisAlignment.spaceBetween,
            //   children: [
            //     Text(model.sTitle,style: TextStyle(color: Colors.grey,fontSize: 10)),
            //     Container(
            //       height: 25,
            //       alignment: Alignment.bottomRight,
            //       child:IconButton(
            //         icon: Image.asset('images/dele.png',),
            //         onPressed: (){
            //           showDialog(
            //               barrierDismissible: true,//是否点击空白区域关闭对话框,默认为true，可以关闭
            //               context: context,
            //               builder: (BuildContext context) {
            //                 var list = [];
            //                 list.add('色情低俗');
            //                 list.add('政治敏感');
            //                 list.add('广告');
            //                 list.add('令人恶心');
            //                 list.add('其他');
            //                 return BottomSheetWidget(
            //                   list: list,
            //                   onItemClickListener: (index) async {
            //                     // LKToast.toast(context,msg: '举报成功，我们将随后处理您的举报');
            //                     BotToast.showText(text: '举报成功，我们将随后处理您的举报');
            //                     print( list[index]);
            //                     Navigator.pop(context);
            //                   },
            //                 );
            //               });
            //         },
            //       ),
            //     ),
            //   ],
            // ),
            // Divider(color: Colors.grey[180],endIndent: 15,indent: 15,),
            Container(
              margin: EdgeInsets.only(left: 15,right: 15),
              color:AppColor.lineColor,
              height: 0.5,
              width: Get.width,
            )
          ],
        )
    );
  }

  /// 左图右文
  getRowleftPicRightText(int a){

    NewsListModel model = dataList[a];

    return Container(
        color: Colors.white,
        child: Column(
          children: [
            Row(
              mainAxisAlignment:MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  margin: const EdgeInsets.only(top: 0,left: 15),
                  clipBehavior: Clip.antiAlias,
                  decoration:  const BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(8.0)),
                    color: Colors.white,
                  ),
                  child: Container(
                    clipBehavior: Clip.antiAlias,
                    decoration:  const BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(8.0)),
                    ),
                    width: 100,
                    height:65,
                    // child: Image.network(itme.appImages.length == 0?'':'${Address.homeHost}${itme.appImages[0].image}',width: 75,height: 120,fit: BoxFit.cover,),
                    child: ExtendedImage.network(
                      '${Address.homeHost}${model.images}',fit: BoxFit.cover,cache: true,
                    ),

                  ),
                ),
                Container(
                  width: Get.width/3*2,
                  // color: Colors.yellow,
                  constraints: BoxConstraints(
                      maxHeight: 90,
                      minHeight: 40
                  ),
                  padding: EdgeInsets.only(left: 15,top: 10,right: 15),
                  child:  Column(
                    crossAxisAlignment:CrossAxisAlignment.start,
                    children: [
                      Text(model.title,style: TextStyle(fontWeight: FontWeight.w400,
                          fontSize: titleFontSize),maxLines: 2,overflow: TextOverflow.ellipsis,),
                      // SizedBox(height: 1,),
                      SizedBox(height: 20,),
                      Row(
                        children: [
                          Text('${model.dateBeauty}',style: TextStyle(fontSize: 10,color: AppColor.smallTextColor),),
                          SizedBox(width: 5,),
                          Text('${model.comments}评论',style: TextStyle(fontSize: 10,color: AppColor.smallTextColor),),
                        ],
                      )
                    ],
                  ),
                ),
              ],
            ),
            Container(
              margin: EdgeInsets.only(left: 15,right: 15),
              color:AppColor.lineColor,
              height: 0.5,
              width: Get.width,
            )
          ],
        )
    );
  }

  ///上文下三图
  getRowTopTextBottomThree(int a){
    NewsListModel model = dataList[a];

    return Container(
      child: Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Container(
            margin:EdgeInsets.only(left: 15,top: 10,right: 15),
            child:Text(model.title,style: TextStyle(fontWeight: FontWeight.w400,fontSize: titleFontSize),maxLines: 2,),
          ),
          Container(
            clipBehavior: Clip.antiAliasWithSaveLayer,
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(8)),
            margin: EdgeInsets.only(left: 15,right: 15,top: 5),
            // height:180,
            // color: Colors.red,
            width: Get.width,
            child:  GridView.builder(
              padding: EdgeInsets.all(0),
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              gridDelegate:  SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 3,
                mainAxisSpacing: 0,
                crossAxisSpacing: 5,
                childAspectRatio: 1.0/0.6,
              ),

              itemCount: model.cover_images!.length, itemBuilder: (BuildContext context, int a) {
              return Container(
                clipBehavior: Clip.antiAliasWithSaveLayer,
                decoration: BoxDecoration(
                  color: Colors.white,
                ),
                child: Image.network('${Address.homeHost}${model.cover_images![a]}',
                  // cache: false,
                  fit: BoxFit.cover,
                ),

              );
            },),
          ),
          Container(
            padding: EdgeInsets.only(left: 15),

            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Text('${model.dateBeauty}',style: TextStyle(fontSize: 10,color: AppColor.smallTextColor),),
                    SizedBox(width: 5,),
                    Text('${model.comments}评论',style: TextStyle(fontSize: 10,color: AppColor.smallTextColor),),
                  ],
                ),
                Container(
                  padding:EdgeInsets.only(left: 15,top: 1),
                  child: Row(
                    mainAxisAlignment:MainAxisAlignment.spaceBetween,
                    children: [
                      Text(model.sTitle,style: TextStyle(color: Colors.grey,fontSize: 10)),
                      Container(
                        height: 25,
                        alignment: Alignment.bottomRight,
                        child:IconButton(
                          icon: Image.asset('images/dele.png',),
                          onPressed: (){
                            showDialog(
                                barrierDismissible: true,//是否点击空白区域关闭对话框,默认为true，可以关闭
                                context: context,
                                builder: (BuildContext context) {
                                  var list = [];
                                  list.add('色情低俗');
                                  list.add('政治敏感');
                                  list.add('广告');
                                  list.add('令人恶心');
                                  list.add('其他');
                                  return BottomSheetWidget(
                                    list: list,
                                    onItemClickListener: (index) async {
                                      BotToast.showText(text: '举报成功，随后我们将处理你的举报');
                                      print( list[index]);
                                      Navigator.pop(context);
                                    },
                                  );
                                });
                          },
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 15,right: 15),
            color: AppColor.lineColor,
            width: Get.width,
            height: 0.5,
          )
        ],
      ),
    );
  }

  ///上文下一图
  getRowTopTextBottomOne(int a){

    NewsListModel model = dataList[a];


    return Container(

      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            padding:EdgeInsets.only(top: 10,left: 15,right: 15),
            child:Text(model.title,style: TextStyle(fontWeight: FontWeight.w400,
                fontSize: titleFontSize
            ),maxLines: 2,),
          ),
          Container(
            height: 150,
            margin: EdgeInsets.only(left: 15,right: 15,top: 10),
            child: Flex(
              direction: Axis.horizontal,
              children: [
                Expanded(
                  flex: 1,
                  child: Container(
                    clipBehavior: Clip.antiAlias,
                    decoration:  BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(8.0)),
                      //设置四周边框
                      // border: Border.all(width: 1, color: AppColor.bgColor),
                    ),

                    // child: Image.network('${Address.homeHost}${model.images}',width: 75,height: 120,fit: BoxFit.cover,),
                    child:
                    // ExtendedImage.network(
                    //   '${Address.homeHost}${model.images}',
                    //   fit: BoxFit.cover,
                    //   cache: true,
                    // ),
                    CachedNetworkImage(
                      placeholder: (context,url)=>new Container(
                        child: new Center(
                          child: new CupertinoActivityIndicator(),
                          // child: Image.asset('images/download-5.png',fit: BoxFit.fill,width: double.infinity,),
                        ),
                      ),
                      imageUrl: '${Address.homeHost}${model.images}',
                      fit: BoxFit.cover,

                    ),
                  ),
                ),
              ],
            ),
          ),

          Container(
            padding: EdgeInsets.only(left: 15),
            child: Row(
              mainAxisAlignment:MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Text('${model.souce}',style: TextStyle(color: Colors.grey,fontSize: 10),),
                    SizedBox(width: 8,),
                    Text('${model.comments} 评论',style: TextStyle(color: Colors.grey,fontSize: 10),),
                    SizedBox(width: 8,),
                    Text(model.dateBeauty,style: TextStyle(color:Colors.grey,fontSize: 10)),
                  ],
                ),
                Container(
                  height: 25,
                  alignment: Alignment.bottomRight,
                  child:IconButton(
                    icon: Image.asset('images/dele.png',),
                    onPressed: (){
                      showDialog(
                          barrierDismissible: true,//是否点击空白区域关闭对话框,默认为true，可以关闭
                          context: context,
                          builder: (BuildContext context) {
                            var list = [];
                            list.add('色情低俗');
                            list.add('政治敏感');
                            list.add('广告');
                            list.add('令人恶心');
                            list.add('其他');
                            return BottomSheetWidget(
                              list: list,
                              onItemClickListener: (index) async {
                                BotToast.showText(text: '举报成功，随后我们将处理你的举报');
                                print( list[index]);
                                Navigator.pop(context);
                              },
                            );
                          });
                    },
                  ),
                ),

              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 15,right: 15),
            color: AppColor.lineColor,
            width: Get.width,
            height: 0.5,
          )
        ],
      ),
    );
  }

  ///上图下文
  getRowTopPicBottomText(int a){

    NewsListModel model = dataList[a];

    return Container(

      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            height: 150,
            margin: EdgeInsets.all(10),
            child: Flex(
              direction: Axis.horizontal,
              children: [
                Expanded(
                  flex: 1,
                  child: Container(
                    clipBehavior: Clip.antiAlias,
                    decoration: new BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(5.0)),
                    ),

                    // child: Image.network(itme.appImages.length == 0?'':'${Address.homeHost}${itme.appImages[0].image}',width: 75,height: 120,fit: BoxFit.cover,),
                    child:ExtendedImage.network('${Address.homeHost}${model.images}',fit: BoxFit.cover,),

                  ),
                ),
              ],
            ),
          ),

          Container(

            padding:EdgeInsets.only(left: 15,top: 0,right: 15),
            child:Text(model.title,style: TextStyle(fontWeight: FontWeight.w400,fontSize: titleFontSize),maxLines: 2,),
          ),

          Container(

            // color: Colors.red,
            padding: EdgeInsets.only(left:15),
            child: Row(
              mainAxisAlignment:MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Text(model.dateBeauty,style: TextStyle(color:AppColor.smallTextColor,fontSize: 10)),
                    SizedBox(width: 5,),
                    Text('${model.comments}评论',style: TextStyle(color: AppColor.smallTextColor,fontSize: 10),)
                  ],
                ),

                Container(
                  height: 25,
                  alignment: Alignment.bottomRight,
                  child:IconButton(
                    icon: Image.asset('images/dele.png',),
                    onPressed: (){
                      showDialog(
                          barrierDismissible: true,//是否点击空白区域关闭对话框,默认为true，可以关闭
                          context: context,
                          builder: (BuildContext context) {
                            var list = [];
                            list.add('色情低俗');
                            list.add('政治敏感');
                            list.add('广告');
                            list.add('令人恶心');
                            list.add('其他');
                            return BottomSheetWidget(
                              list: list,
                              onItemClickListener: (index) async {
                                BotToast.showText(text: '举报成功，随后我们将处理你的举报');
                                print( list[index]);
                                Navigator.pop(context);
                              },
                            );
                          });
                    },
                  ),
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 15,right: 15),
            width: Get.width,
            height: 0.5,
            color: AppColor.lineColor,
          )
        ],
      ),
    );
  }

  /// 上文下视频
  getRowTopTextBottomVideo(int a){
    NewsListModel model = dataList[a];

    return Container(
      child: Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Container(
            padding:EdgeInsets.only(left: 15,right: 15,top: 10),
            child:Text(model.title,style: TextStyle(fontWeight: FontWeight.w400,fontSize: titleFontSize),maxLines: 2,),
          ),
          Container(
            // color: Colors.yellow,
            padding: EdgeInsets.only(left: 15,right: 15,top: 5),
            child: Flex(
              direction: Axis.horizontal,
              children: [
                Expanded(
                    flex: 1,
                    child: Stack(
                      children: [
                        Container(
                          height: 180,
                          clipBehavior: Clip.antiAliasWithSaveLayer,
                          decoration: const BoxDecoration(
                            color: Colors.red,
                            borderRadius: BorderRadius.all(Radius.circular(8.0)),
                          ),
                          // color: Colors.pink,
                          child: ChewiePlayerPage('${model.vurl}&preview=1'),
                          // VideoPlayer(_videoPlayerController1)
                          // Chewie(
                          //   controller: _chewieController,
                          // ),
                        ),
                        // Align(
                        //   child: GestureDetector(
                        //     onTap: (){
                        //       _videoPlayerController1.play();
                        //       print('play');
                        //     },
                        //
                        //     child: Container(
                        //       // color: Colors.transparent,
                        //       alignment: Alignment.center,
                        //       width: 100,
                        //       height: 180,
                        //       child: Image.asset('images/play.png',fit: BoxFit.cover,width: 25,height: 25,),
                        //     ),
                        //   ),
                        // ),
                      ],
                    )
                ),
              ],
            ),
          ),
          Container(
            color: Colors.white,
            padding: EdgeInsets.only(left: 15),
            child: Row(
              mainAxisAlignment:MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Text(model.dateBeauty,style: TextStyle(color: AppColor.smallTextColor,fontSize: 10)),
                    SizedBox(width: 5,),
                    Text('${model.comments}评论',style: TextStyle(color: AppColor.smallTextColor,fontSize: 10),)
                  ],
                ),
                Container(
                  height: 25,
                  alignment: Alignment.bottomRight,
                  child:IconButton(
                    icon: Image.asset('images/dele.png',),
                    onPressed: (){
                      showDialog(
                          barrierDismissible: true,//是否点击空白区域关闭对话框,默认为true，可以关闭
                          context: context,
                          builder: (BuildContext context) {
                            var list = [];
                            list.add('色情低俗');
                            list.add('政治敏感');
                            list.add('广告');
                            list.add('令人恶心');
                            list.add('其他');
                            return BottomSheetWidget(
                              list: list,
                              onItemClickListener: (index) async {
                                BotToast.showText(text: '举报成功，随后我们将处理你的举报');
                                print( list[index]);
                                Navigator.pop(context);
                              },
                            );
                          });
                    },
                  ),
                ),

              ],
            ),
          ),

          Container(
            margin: EdgeInsets.only(left: 15,right: 15),
            color: AppColor.lineColor,
            width: Get.width,
            height: 0.5,
          ),

        ],
      ),
    );

  }

  /// 创建三张图片
  List<Widget>_threePic(int a){

    List <Widget>page = [];
    for(int i = 0;i<3;i++){
      page.add(Expanded(
        flex: 1,
        child:Container(
          padding: EdgeInsets.all(5),
          child:Container(
            clipBehavior: Clip.antiAlias,
            decoration:  BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(5.0)),
            ),
            width: 120,
            height:70,
            // child: Image.network(itme.appImages.length == 0?'':'${Address.homeHost}${itme.appImages[0].image}',width: 75,height: 120,fit: BoxFit.cover,),
            child: CachedNetworkImage(
              placeholder: (context,url)=>new Container(
                child: new Center(
                  // child: new CircularProgressIndicator(),
                  child: Image.asset('images/download-5.png'),
                ),
                width: 120.0,
                height: 70.0,
              ),
              imageUrl: '${dataList[a]['app_images'][i]['image']}',
              fit: BoxFit.cover,

            ),
          ) ,
        ),));
    }
    return page;
  }
}
